import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class HomePageTest {

	private static WebDriver driver;

	@BeforeClass
	public static void given() {
		driver = new HtmlUnitDriver();
		driver.get("http://localhost:8080/web1");
	}

	@Test
	public void welcomePageIsAccessible() {
		assertThat(driver.getTitle(), is("Web1"));
	}

	@Test
	public void bodyIsWelcomeMessage() {
		WebElement body = driver.findElement(By.tagName("body"));

		assertThat(body.getText(), is("Welcome"));
	}

	@AfterClass
	public static void release() {
		driver.quit();
	}
}
